package com.flink.paimon;

import org.apache.paimon.catalog.Catalog;
import org.apache.paimon.catalog.Identifier;
import org.apache.paimon.flink.FlinkCatalogFactory;
import org.apache.paimon.options.Options;
import org.apache.paimon.schema.SchemaChange;

import java.util.ArrayList;
import java.util.List;

/**
 * AlertTable
 *
 * @author caizhiyang
 * @since 2024-05-07
 */
public class AlertTable {
    public static void main(String[] args) throws Exception{
        System.setProperty("HADOOP_USER_NAME", "root");
        Identifier identifier = Identifier.create("default", "paimon_test_update");
        Options catalogOptions = new Options();
        catalogOptions.set("warehouse", "hdfs://172.0.107.57:8082/paimon/main");
        Catalog.Loader catalogLoader =
                () -> FlinkCatalogFactory.createPaimonCatalog(catalogOptions);
        Catalog catalog = catalogLoader.load();


        List<SchemaChange> schemaChangeList = new ArrayList<>();
        schemaChangeList.add(SchemaChange.renameColumn("nickname", "myname"));
        catalog.alterTable(identifier, schemaChangeList, false);
    }
}
